package ma.ensias.healthme.admin;


import ma.ensias.healthme.R;
import ma.ensias.healthme.dao.PersonneDao;
import ma.ensias.healthme.entities.Personne;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class InfoCompteActivity extends FragmentActivity {

	Personne p;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		p=(Personne)getIntent().getSerializableExtra("personne");
		
		TextView np=(TextView)findViewById(R.id.Info_NP);
		TextView role=(TextView)findViewById(R.id.Info_Role);
		TextView email=(TextView)findViewById(R.id.Info_Email);
		TextView login=(TextView)findViewById(R.id.Info_Login);
		TextView pass=(TextView)findViewById(R.id.Info_Passe);
		
		np.setText(p.getNom()+" "+p.getPrenom());
		role.setText(p.getRole());
		email.setText(p.getEmail());
		login.setText(p.getLogin());
		pass.setText(p.getPass());
		
		
		Button retour = (Button) findViewById(R.id.button3);
		
		retour.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	finish();
                
            }
        });
		
		Button supprimer = (Button) findViewById(R.id.button2);
		
		supprimer.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	showDialog();
            }
        });
		
		Button modifier = (Button) findViewById(R.id.button1);
		
		modifier.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	finish();
                
            }
        });
		setContentView(R.layout.activity_info_compte);
	}

	void showDialog() {
        DialogFragment newFragment = MyAlertDialogFragment
                .newInstance(R.string.confirmation);
        newFragment.show(getSupportFragmentManager(),"dialog");
    }

    public void doPositiveClick() {
    	PersonneDao dao=new PersonneDao();
    	dao.delete(p.getId());
    }

    public void doNegativeClick() {
        // Do stuff here.
        Log.i("FragmentAlertDialog", "Negative click!");
    }
	
	
	
	
	
	/*public void finish() {
		/*finish();
		startActivity(new Intent(this,ListComptesActivity.class));
		InfoCompteActivity.this.finish();
		
	 }*/
}
